import PredictStore from '@/store/predict';
import { createStoreBindings } from '@/miniprogram_npm/mobx-miniprogram-bindings/index';

Page({
    data: {},

    onLoad() {
        this.storeBindings = createStoreBindings(this, {
            store: PredictStore,
            fields: ['tableColumns', 'tableData']
        });
    },

    onUnload() {
        this.storeBindings.destroyStoreBindings();
    },

    getData(e) {
        let data = e.detail.data[0];
        let keys = Object.keys(data[0]);
        let columns = [];
        keys.forEach((key) => {
            columns.push({
                title: key,
                key: key
            });
        });
        PredictStore.setTableData(data);
    }
});
